function gridMainContainer_ResizeFcn(h, e)
%GRIDMAINCONTAINER_RESIZEFCN Summary of this function goes here
%   Detailed explanation goes here

% Isn't invoked any longer

h_parent= get(h, 'parent');
h_flow = findobj('parent', h, 'Type', 'uiflowcontainer');
parent_unit= get(h_parent, 'units');
set(h_parent, 'units', 'pixels');
parent_position= get(h_parent, 'position');
parent_width= parent_position(3);
parent_hight= parent_position(4);

parent_aspectratio= parent_width/(parent_hight);
vertical_mode= parent_width/(parent_hight-160);
horizontal_mode= parent_width/(parent_hight-80);

% FIXME Quick'n'Dirty come on make me KISS
% TODO Make the flowcontainerbehaviour dependebale from screen aspect
% ration

if parent_aspectratio < (16/10)
    if vertical_mode < horizontal_mode
        setappdata(h, 'rowdefinitions', [NaN, 80]);
        setappdata(h, 'columndefinitions', [NaN]);
        set(h_flow, 'FlowDirection', 'lefttoright');
    else
        setappdata(h, 'rowdefinitions', [NaN, 160]);
        setappdata(h, 'columndefinitions', [NaN]);
        set(h_flow, 'FlowDirection', 'topdown');
    end
else
    if vertical_mode > horizontal_mode
        setappdata(h, 'rowdefinitions', [NaN, 80]);
        setappdata(h, 'columndefinitions', [NaN]);
        set(h_flow, 'FlowDirection', 'lefttoright');
    else
        setappdata(h, 'rowdefinitions', [NaN, 160]);
        setappdata(h, 'columndefinitions', [NaN]);
        set(h_flow, 'FlowDirection', 'topdown');
    end
end

uigridcontainer_ResizeFcn(h, e);
end

